{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import tushare as ts\n",
    "import pandas as pd\n",
    "from plotly.graph_objs import *\n",
    "import os\n",
    "import datetime\n",
    "ts.set_token('ac8805887aa21d24fd5ec47a4ae9e7a09804ebaeedea93352a7b13d2e8f08e46')\n",
    "start1 = '2017-05-01'\n",
    "end1 = '2017-07-07'\n",
    "global DETA\n",
    "DETA = 0.2/15\n",
    "\n",
    "# 这里定义一个函数，可以应用到每一行，设置axis=1就是应用到每一行的意思；如果设置axis=0，就是应用于每一列的意思\n",
    "def openMinusLow(x):\n",
    "    return float(x['open'])-float(x['low'])\n",
    "\n",
    "# 获取股票的名称\n",
    "def get_stock_name(stock_code):\n",
    "    df = ts.get_realtime_quotes(stock_code)\n",
    "    return df['name'][0]\n",
    "\n",
    "def get_stock_operate_date(stock_code):\n",
    "    print('统计股票：'+stock_code\n",
    "          +'(' + get_stock_name(stock_code) + ')'\n",
    "          +'\\n* 当天上涨率高于2%的天数。')\n",
    "    print('* 说明：open-low表示开盘价和最低价相减的结果，越接近说明开盘买入基本上就是最低价')\n",
    "    print('        然后在看price_change，假设高于0.3以上，400股就能赚100块以上')\n",
    "    print(         'price_change=收盘价-昨收价，p_change=price_change/昨收价*100%')\n",
    "    print('-------------------------------------------------------------------------------')\n",
    "    start0 = '2017-05-02' # 起始日期，可以修改\n",
    "    end0 = str(datetime.date.today())    # 直到今天\n",
    "    df_h_data = ts.get_hist_data(stock_code,start=start0,end=end0)\n",
    "    # print(df_h_data[['open','high','close','low','volume','price_change', 'p_change']].head(2))\n",
    "    # 获取收盘价比昨天收盘价高0.1以上，并且开盘价低于收盘价的日期；\n",
    "    global DETA\n",
    "    df_price_change_list = df_h_data[\n",
    "        (df_h_data['price_change'] > DETA * df_h_data['open'])\n",
    "        &(df_h_data['open'] < df_h_data['close'])\n",
    "    ]\n",
    "    df_temp = df_price_change_list.apply(openMinusLow, axis=1) # 对每一行执行函数\n",
    "    # 用insert就没有SettingWithCopyWarning警告了\n",
    "    df_price_change_list.insert(0,'open-low',df_temp)\n",
    "    print(df_price_change_list.index)\n",
    "    return df_price_change_list\n",
    "\n",
    "# 获取可以操作的交易日里面的买入点时间\n",
    "def get_low_price_moment(stock_code, df_stock_operate):\n",
    "    for i_date in df_stock_operate.index:\n",
    "        \n",
    "        #获取某一天的历史价格变动情况，好像间隔周期是3秒\n",
    "        df_tick_data = ts.get_tick_data(stock_code,date=i_date) \n",
    "        lowPrice = float(df_stock_operate['low'][i_date])\n",
    "        highPrice = float(df_stock_operate['high'][i_date])\n",
    "        print('--------------------Data: '+ i_date+'--------------------')\n",
    "        print('--------------------LowestPrice :'+str(lowPrice)+'---------------------')\n",
    "        print('--------------------HighestPrice :'+str(highPrice)+'-------------------')\n",
    "        print(df_tick_data.head(2))\n",
    "        print('...... total: '+str(len(df_tick_data)))\n",
    "        \n",
    "        df_moment = df_tick_data[\n",
    "            (df_tick_data['price']-lowPrice < 0.05)\n",
    "        ]\n",
    "        size = len(df_moment)\n",
    "        if size != 0:\n",
    "            #print('df_moment.size = '+str(size))\n",
    "            #print(df_moment.iloc[0,0]) #iloc[column, row]，不需要知道行号和列号，直接获取单位元素\n",
    "            #print(df_moment.iloc[size-1,0])\n",
    "            datetimeEnd = df_moment.iloc[0,0]\n",
    "            datatimeStart = df_moment.iloc[size-1,0]\n",
    "            print('--->从 '+datatimeStart+ ' 到 '+ datetimeEnd + '有合适的时间点：'+str(size)+'个')\n",
    "            print(df_moment)\n",
    "        else:\n",
    "            print('df_moment is empty')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "统计股票：000507(珠海港)\n",
      "* 当天上涨率高于2%的天数。\n",
      "* 说明：open-low表示开盘价和最低价相减的结果，越接近说明开盘买入基本上就是最低价\n",
      "        然后在看price_change，假设高于0.3以上，400股就能赚100块以上\n",
      "price_change=收盘价-昨收价，p_change=price_change/昨收价*100%\n",
      "-------------------------------------------------------------------------------\n",
      "Index(['2017-07-11', '2017-07-05', '2017-06-27', '2017-06-23', '2017-06-19',\n",
      "       '2017-06-16', '2017-06-13', '2017-06-08', '2017-06-07', '2017-06-06',\n",
      "       '2017-06-02', '2017-05-31', '2017-05-24', '2017-05-16', '2017-05-15',\n",
      "       '2017-05-12', '2017-05-11', '2017-05-09', '2017-05-03', '2017-05-02'],\n",
      "      dtype='object', name='date')\n",
      "--------------------Data: 2017-07-11--------------------\n",
      "--------------------LowestPrice :11.74---------------------\n",
      "--------------------HighestPrice :12.35-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03   12.1     --   12063  14596230   买盘\n",
      "1  14:57:00   12.1   0.01     188    227480   买盘\n",
      "...... total: 4629\n",
      "--->从 09:25:03 到 09:30:00有合适的时间点：2个\n",
      "          time  price change  volume   amount type\n",
      "4627  09:30:00  11.75     --      57    66975   买盘\n",
      "4628  09:25:03  11.75  11.75    3193  3751775   买盘\n",
      "--------------------Data: 2017-07-05--------------------\n",
      "--------------------LowestPrice :12.16---------------------\n",
      "--------------------HighestPrice :12.56-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  12.44     --   11487  14289828   卖盘\n",
      "1  14:57:00  12.44     --     233    289852   卖盘\n",
      "...... total: 4572\n",
      "--->从 09:36:27 到 13:09:06有合适的时间点：197个\n",
      "          time  price change  volume   amount type\n",
      "2093  13:09:06  12.19     --     134   163346   卖盘\n",
      "2094  13:09:03  12.19     --     614   748466   卖盘\n",
      "2095  13:09:00  12.19  -0.01      51    62169   卖盘\n",
      "2101  13:08:36  12.19  -0.01      39    47541   卖盘\n",
      "2104  13:08:24  12.19  -0.01      90   109710   卖盘\n",
      "2111  13:08:03  12.19  -0.01       3     3657   卖盘\n",
      "2116  13:07:48  12.19  -0.01      20    24380   卖盘\n",
      "2118  13:07:42  12.19     --     105   127995   卖盘\n",
      "2119  13:07:39  12.19     --       1     1219   卖盘\n",
      "2120  13:07:36  12.19  -0.01       2     2438   卖盘\n",
      "2122  13:07:30  12.19     --      22    26818   卖盘\n",
      "2123  13:07:27  12.19     --      20    24380   卖盘\n",
      "2124  13:07:24  12.19     --     376   458344   买盘\n",
      "2125  13:07:21  12.19     --      33    40227   买盘\n",
      "2126  13:07:18  12.19     --       6     7314   买盘\n",
      "2127  13:07:15  12.19     --     114   138966   买盘\n",
      "2128  13:07:12  12.19     --      13    15847   买盘\n",
      "2129  13:07:09  12.19     --      59    71921   买盘\n",
      "2130  13:07:03  12.19     --      32    39008   买盘\n",
      "2131  13:07:00  12.19     --      11    13409   买盘\n",
      "2132  13:06:57  12.19     --      22    26818   买盘\n",
      "2133  13:06:54  12.19     --      22    26818   买盘\n",
      "2134  13:06:51  12.19     --       2     2438   买盘\n",
      "2135  13:06:48  12.19     --      24    29256   买盘\n",
      "2136  13:06:45  12.19     --      16    19504   买盘\n",
      "2137  13:06:42  12.19   0.01       9    10971   买盘\n",
      "2138  13:06:39  12.18     --      93   113274   卖盘\n",
      "2139  13:06:36  12.18     --      34    41412   卖盘\n",
      "2140  13:06:33  12.18  -0.01      35    42630   卖盘\n",
      "2141  13:06:27  12.19     --      13    15847   买盘\n",
      "...        ...    ...    ...     ...      ...  ...\n",
      "2327  11:26:48  12.19  -0.02     535   652165   卖盘\n",
      "2409  11:22:39  12.19  -0.01      90   109710   卖盘\n",
      "2411  11:22:33  12.19  -0.01      40    48760   卖盘\n",
      "2413  11:22:27  12.19  -0.01      30    36570   卖盘\n",
      "2415  11:22:21  12.19     --     285   347415   卖盘\n",
      "2416  11:22:18  12.19     --     377   459563   卖盘\n",
      "2417  11:22:15  12.19  -0.01      69    84111   卖盘\n",
      "2419  11:22:09  12.19  -0.01     112   136528   卖盘\n",
      "2422  11:22:00  12.19  -0.01     195   237705   卖盘\n",
      "2424  11:21:54  12.19  -0.01     106   129214   卖盘\n",
      "2426  11:21:48  12.19     --      29    35351   卖盘\n",
      "2427  11:21:45  12.19     --     200   243800   买盘\n",
      "2428  11:21:42  12.19     --      17    20723   买盘\n",
      "2429  11:21:39  12.19  -0.01     166   202354   卖盘\n",
      "2432  11:21:30  12.19  -0.01     129   157251   卖盘\n",
      "4371  09:39:57  12.19  -0.01     145   176755   卖盘\n",
      "4373  09:39:51  12.19     --      82    99958   卖盘\n",
      "4374  09:39:48  12.19  -0.03     199   242581   卖盘\n",
      "4376  09:39:42  12.19   0.01      58    70702   卖盘\n",
      "4377  09:39:39  12.18     --     295   359310   卖盘\n",
      "4378  09:39:36  12.18  -0.01     129   157122   卖盘\n",
      "4379  09:39:33  12.19     --     412   502228   买盘\n",
      "4380  09:39:30  12.19     --     134   163614   买盘\n",
      "4381  09:39:27  12.19     --     603   735057   买盘\n",
      "4382  09:39:24  12.19     --      81    98739   买盘\n",
      "4383  09:39:21  12.19  -0.05    6062  7389578   卖盘\n",
      "4433  09:36:51  12.19  -0.01     353   430307   卖盘\n",
      "4436  09:36:42  12.18  -0.02     269   327642   卖盘\n",
      "4438  09:36:36  12.19  -0.01     113   137747   卖盘\n",
      "4441  09:36:27  12.19  -0.05    2954  3600926   卖盘\n",
      "\n",
      "[197 rows x 6 columns]\n",
      "--------------------Data: 2017-06-27--------------------\n",
      "--------------------LowestPrice :12.9---------------------\n",
      "--------------------HighestPrice :13.88-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  13.48     --   28015  37764772   买盘\n",
      "1  14:57:00  13.48     --     396    533808   买盘\n",
      "...... total: 4717\n",
      "--->从 09:25:03 到 09:30:00有合适的时间点：2个\n",
      "          time  price change  volume   amount type\n",
      "4715  09:30:00   12.9     --       0        0   卖盘\n",
      "4716  09:25:03   12.9   12.9    4448  5739106   买盘\n",
      "--------------------Data: 2017-06-23--------------------\n",
      "--------------------LowestPrice :12.01---------------------\n",
      "--------------------HighestPrice :13.1-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  12.94     --   19630  25402203   买盘\n",
      "1  14:57:00  12.94   0.01     287    371986   买盘\n",
      "...... total: 4681\n",
      "df_moment is empty\n",
      "--------------------Data: 2017-06-19--------------------\n",
      "--------------------LowestPrice :13.17---------------------\n",
      "--------------------HighestPrice :13.84-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  13.52   0.08   23926  32349033   买盘\n",
      "1  14:57:00  13.44  -0.01     447    600768   卖盘\n",
      "...... total: 4705\n",
      "--->从 09:43:24 到 09:59:00有合适的时间点：19个\n",
      "          time  price change  volume   amount type\n",
      "4123  09:59:00  13.20     --     160   211200   卖盘\n",
      "4124  09:58:57  13.20  -0.01     366   483120   卖盘\n",
      "4129  09:58:42  13.20     --     372   491040   卖盘\n",
      "4130  09:58:39  13.20     --     591   780120   卖盘\n",
      "4131  09:58:36  13.20     --    1028  1356960   卖盘\n",
      "4132  09:58:33  13.20     --     461   608520   卖盘\n",
      "4133  09:58:30  13.20   0.01    1227  1619640  中性盘\n",
      "4134  09:58:27  13.19  -0.02     271   357449   卖盘\n",
      "4136  09:58:21  13.19     --     804  1060476   卖盘\n",
      "4137  09:58:18  13.19     --     695   916705   卖盘\n",
      "4138  09:58:15  13.19     --     831  1097025   卖盘\n",
      "4139  09:58:12  13.19     --     411   542109   卖盘\n",
      "4140  09:58:09  13.19  -0.02    1283  1692659   卖盘\n",
      "4430  09:43:39  13.20     --    1790  2362800   卖盘\n",
      "4431  09:43:36  13.20     --     482   636240   卖盘\n",
      "4432  09:43:33  13.20     --    1987  2622840   买盘\n",
      "4433  09:43:30  13.20   0.02     667   880440   买盘\n",
      "4434  09:43:27  13.18  -0.01     975  1285050   卖盘\n",
      "4435  09:43:24  13.19  -0.02     852  1123788   卖盘\n",
      "--------------------Data: 2017-06-16--------------------\n",
      "--------------------LowestPrice :12.51---------------------\n",
      "--------------------HighestPrice :13.97-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  13.33     --   45119  60143627   卖盘\n",
      "1  14:57:00  13.33     --    1187   1582271   买盘\n",
      "...... total: 4731\n",
      "--->从 09:35:42 到 09:57:24有合适的时间点：146个\n",
      "          time  price change  volume   amount type\n",
      "4181  09:57:24  12.54     --     498   624492   卖盘\n",
      "4182  09:57:21  12.54     --      39    48906   卖盘\n",
      "4183  09:57:18  12.54     --     130   163020   卖盘\n",
      "4184  09:57:15  12.54     --      47    58937   买盘\n",
      "4185  09:57:12  12.54   0.01    1174  1472196   买盘\n",
      "4186  09:57:09  12.53     --      88   110264   卖盘\n",
      "4187  09:57:06  12.53  -0.01     230   288190   卖盘\n",
      "4188  09:57:03  12.54     --     195   244529   买盘\n",
      "4189  09:57:00  12.54     --      29    36366   买盘\n",
      "4190  09:56:57  12.54     --      24    30095   买盘\n",
      "4191  09:56:54  12.54   0.01    1321  1656534   买盘\n",
      "4192  09:56:51  12.53     --     496   621488   卖盘\n",
      "4193  09:56:48  12.53  -0.01     272   340816   卖盘\n",
      "4194  09:56:45  12.54     --     398   499091   买盘\n",
      "4195  09:56:42  12.54   0.01      39    48906   买盘\n",
      "4196  09:56:39  12.53     --      82   102746   卖盘\n",
      "4197  09:56:36  12.53     --    1140  1428420   买盘\n",
      "4198  09:56:33  12.53     --     572   716716   卖盘\n",
      "4199  09:56:30  12.53     --      77    96481   卖盘\n",
      "4200  09:56:27  12.53     --     126   157878   卖盘\n",
      "4201  09:56:24  12.53     --     353   442309   卖盘\n",
      "4202  09:56:21  12.53     --     160   200480   卖盘\n",
      "4203  09:56:18  12.53     --     182   228046   卖盘\n",
      "4204  09:56:15  12.53  -0.01     218   273154   卖盘\n",
      "4205  09:56:12  12.54   0.01     470   589380   买盘\n",
      "4206  09:56:09  12.53     --     191   239323   卖盘\n",
      "4207  09:56:06  12.53   0.01    1021  1279313   买盘\n",
      "4208  09:56:03  12.52     --     216   270432   卖盘\n",
      "4209  09:56:00  12.52     --     180   225360   卖盘\n",
      "4210  09:55:57  12.52  -0.01     261   326772   卖盘\n",
      "...        ...    ...    ...     ...      ...  ...\n",
      "4533  09:39:48  12.54     --     301   377454   买盘\n",
      "4534  09:39:45  12.54     --     343   430121   买盘\n",
      "4535  09:39:42  12.54     --     358   448931   卖盘\n",
      "4536  09:39:39  12.54     --     234   293436   卖盘\n",
      "4537  09:39:36  12.54  -0.01     161   201894   卖盘\n",
      "4539  09:39:30  12.54   0.01     141   176814  中性盘\n",
      "4540  09:39:27  12.53  -0.02     108   135324   卖盘\n",
      "4542  09:39:21  12.53     --     315   394695   卖盘\n",
      "4543  09:39:18  12.53  -0.01     227   284431   卖盘\n",
      "4544  09:39:15  12.54   0.01     393   492821   买盘\n",
      "4545  09:39:12  12.53  -0.02     455   570115   卖盘\n",
      "4552  09:38:51  12.54  -0.03      96   120383   卖盘\n",
      "4559  09:38:30  12.54     --     512   642048   卖盘\n",
      "4560  09:38:27  12.54     --     135   169290   卖盘\n",
      "4561  09:38:24  12.54     --     740   927959   买盘\n",
      "4562  09:38:21  12.54   0.01     153   191862   买盘\n",
      "4563  09:38:18  12.53  -0.02     528   661584   卖盘\n",
      "4602  09:36:21  12.54     --     814  1020755   买盘\n",
      "4603  09:36:18  12.54     --     535   670890   卖盘\n",
      "4604  09:36:15  12.54     --     601   753654   卖盘\n",
      "4605  09:36:12  12.54   0.01     326   408804   买盘\n",
      "4606  09:36:09  12.53  -0.01     450   563850   卖盘\n",
      "4607  09:36:06  12.54     --     464   581856   买盘\n",
      "4608  09:36:03  12.54   0.01    1586  1988843   买盘\n",
      "4609  09:36:00  12.53     --     533   667849   卖盘\n",
      "4610  09:35:57  12.53  -0.02    1044  1308132   卖盘\n",
      "4612  09:35:51  12.54     --     437   547998   卖盘\n",
      "4613  09:35:48  12.54     --     293   367422   卖盘\n",
      "4614  09:35:45  12.54   0.01     122   152988  中性盘\n",
      "4615  09:35:42  12.53  -0.03     225   281925   卖盘\n",
      "\n",
      "[146 rows x 6 columns]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--------------------Data: 2017-06-13--------------------\n",
      "--------------------LowestPrice :12.42---------------------\n",
      "--------------------HighestPrice :13.45-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  13.45     --    7722  10386332   卖盘\n",
      "1  14:57:00  13.45     --     208    279760   卖盘\n",
      "...... total: 4738\n",
      "--->从 11:02:21 到 11:03:15有合适的时间点：17个\n",
      "          time  price change  volume   amount type\n",
      "2871  11:03:15  12.45   0.01     370   460650   买盘\n",
      "2872  11:03:12  12.44     --     339   421716   买盘\n",
      "2873  11:03:09  12.44     --     362   450328   买盘\n",
      "2874  11:03:06  12.44  -0.01     418   519992   卖盘\n",
      "2875  11:03:03  12.45   0.01     708   881460   买盘\n",
      "2876  11:03:00  12.44  -0.01     357   444108   卖盘\n",
      "2877  11:02:57  12.45   0.02     444   552780   买盘\n",
      "2878  11:02:54  12.43  -0.01     619   769417   卖盘\n",
      "2879  11:02:51  12.44  -0.01     338   420472   卖盘\n",
      "2880  11:02:48  12.45   0.02     513   638685   买盘\n",
      "2881  11:02:45  12.43  -0.01     211   262273  中性盘\n",
      "2882  11:02:42  12.44     --     624   776256   卖盘\n",
      "2883  11:02:39  12.44     --    1072  1333568   卖盘\n",
      "2884  11:02:36  12.44  -0.01     488   607072   卖盘\n",
      "2885  11:02:33  12.45   0.01     445   554025  中性盘\n",
      "2886  11:02:30  12.44  -0.02     652   811088   卖盘\n",
      "2889  11:02:21  12.45  -0.01     765   952425   卖盘\n",
      "--------------------Data: 2017-06-08--------------------\n",
      "--------------------LowestPrice :11.56---------------------\n",
      "--------------------HighestPrice :12.46-------------------\n",
      "       time  price change  volume   amount type\n",
      "0  15:00:03  12.46     --    3552  4426738   卖盘\n",
      "1  14:57:00  12.46     --      62    77252   卖盘\n",
      "...... total: 3656\n",
      "--->从 09:40:00 到 09:40:06有合适的时间点：2个\n",
      "          time  price change  volume   amount type\n",
      "3452  09:40:06  11.58  -0.02    1442  1669836   卖盘\n",
      "3454  09:40:00  11.58  -0.03    2842  3291209   卖盘\n",
      "--------------------Data: 2017-06-07--------------------\n",
      "--------------------LowestPrice :10.21---------------------\n",
      "--------------------HighestPrice :11.35-------------------\n",
      "       time  price change  volume   amount type\n",
      "0  15:00:03  11.35     --    1329  1508415   卖盘\n",
      "1  14:57:00  11.35     --       8     9080   卖盘\n",
      "...... total: 1965\n",
      "df_moment is empty\n",
      "--------------------Data: 2017-06-06--------------------\n",
      "--------------------LowestPrice :9.76---------------------\n",
      "--------------------HighestPrice :10.55-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  10.32   0.01   15653  16154721   买盘\n",
      "1  14:57:00  10.31  -0.01     426    439206   卖盘\n",
      "...... total: 4508\n",
      "--->从 09:31:51 到 09:33:27有合适的时间点：30个\n",
      "          time  price change  volume   amount type\n",
      "4437  09:33:27   9.79  -0.01      88    86151   卖盘\n",
      "4440  09:33:18   9.78     --      36    35208   卖盘\n",
      "4441  09:33:15   9.78     --      42    41076   卖盘\n",
      "4442  09:33:12   9.78     --     579   566262   买盘\n",
      "4443  09:33:09   9.78     --     226   221028   买盘\n",
      "4444  09:33:06   9.78   0.01     126   123227   买盘\n",
      "4445  09:33:03   9.77  -0.01     356   347909   卖盘\n",
      "4446  09:33:00   9.78   0.01     251   245477   买盘\n",
      "4447  09:32:57   9.77  -0.01     143   139711   卖盘\n",
      "4448  09:32:54   9.78     --      62    60635   买盘\n",
      "4449  09:32:51   9.78   0.01     220   215160   卖盘\n",
      "4450  09:32:48   9.77   0.01      42    41034  中性盘\n",
      "4451  09:32:45   9.76  -0.02    1081  1055056   卖盘\n",
      "4452  09:32:42   9.78     --     360   352080   买盘\n",
      "4453  09:32:39   9.78   0.01      56    54768   买盘\n",
      "4454  09:32:36   9.77  -0.01     513   501201   卖盘\n",
      "4455  09:32:33   9.78     --     681   666018   卖盘\n",
      "4456  09:32:30   9.78     --      87    85086   卖盘\n",
      "4457  09:32:27   9.78     --     184   179952   卖盘\n",
      "4458  09:32:24   9.78   0.01      72    70416   买盘\n",
      "4459  09:32:21   9.77     --     211   206147   卖盘\n",
      "4460  09:32:18   9.77  -0.01     329   321433   卖盘\n",
      "4461  09:32:15   9.78     --     110   107580   买盘\n",
      "4462  09:32:12   9.78     --     439   429342   卖盘\n",
      "4463  09:32:09   9.78     --    1114  1089492   卖盘\n",
      "4464  09:32:06   9.78     --     237   231785   卖盘\n",
      "4465  09:32:03   9.78  -0.01     398   389244   卖盘\n",
      "4466  09:32:00   9.79     --     107   104752   卖盘\n",
      "4467  09:31:57   9.79  -0.01     127   124332   卖盘\n",
      "4469  09:31:51   9.78  -0.02     383   374574   卖盘\n",
      "--------------------Data: 2017-06-02--------------------\n",
      "--------------------LowestPrice :9.11---------------------\n",
      "--------------------HighestPrice :9.98-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03   9.88   0.03   14623  14447524   买盘\n",
      "1  14:57:00   9.85     --     156    153660   买盘\n",
      "...... total: 4339\n",
      "--->从 09:40:06 到 09:40:09有合适的时间点：2个\n",
      "          time  price change  volume  amount type\n",
      "4134  09:40:09   9.13   0.02     445  406285  中性盘\n",
      "4135  09:40:06   9.11  -0.05     250  227750   卖盘\n",
      "--------------------Data: 2017-05-31--------------------\n",
      "--------------------LowestPrice :9.6---------------------\n",
      "--------------------HighestPrice :10.18-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  10.00   0.01   13507  13507040   买盘\n",
      "1  14:57:00   9.99  -0.01     142    141858   卖盘\n",
      "...... total: 4479\n",
      "df_moment is empty\n",
      "--------------------Data: 2017-05-24--------------------\n",
      "--------------------LowestPrice :8.58---------------------\n",
      "--------------------HighestPrice :9.86-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03   9.82     --   16192  15900544   买盘\n",
      "1  14:57:00   9.82     --     141    138462   买盘\n",
      "...... total: 4370\n",
      "--->从 09:39:24 到 09:39:57有合适的时间点：5个\n",
      "          time  price change  volume   amount type\n",
      "4169  09:39:57   8.61  -0.02     361   310821   卖盘\n",
      "4172  09:39:48   8.61  -0.01     918   790398   卖盘\n",
      "4175  09:39:39   8.61  -0.01     606   521765   卖盘\n",
      "4177  09:39:33   8.61  -0.01     522   449441   卖盘\n",
      "4180  09:39:24   8.60  -0.02    1513  1301180   卖盘\n",
      "--------------------Data: 2017-05-16--------------------\n",
      "--------------------LowestPrice :9.4---------------------\n",
      "--------------------HighestPrice :10.21-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03  10.16     --   14732  14968138   卖盘\n",
      "1  14:57:00  10.16     --     837    850392   卖盘\n",
      "...... total: 4679\n",
      "--->从 09:36:48 到 09:37:18有合适的时间点：10个\n",
      "          time  price change  volume   amount type\n",
      "4531  09:37:18   9.43  -0.01    1043   983549   卖盘\n",
      "4533  09:37:12   9.43   0.01    2312  2180216  中性盘\n",
      "4534  09:37:09   9.42  -0.01     704   663168   卖盘\n",
      "4535  09:37:06   9.43     --    1944  1833192   买盘\n",
      "4536  09:37:03   9.43   0.01    2604  2455572   买盘\n",
      "4537  09:37:00   9.42     --     962   906204   买盘\n",
      "4538  09:36:57   9.42  -0.01    2898  2729916   卖盘\n",
      "4539  09:36:54   9.43   0.01     565   532795   买盘\n",
      "4540  09:36:51   9.42  -0.01     814   766788   卖盘\n",
      "4541  09:36:48   9.43  -0.01    1223  1153289   卖盘\n",
      "--------------------Data: 2017-05-15--------------------\n",
      "--------------------LowestPrice :9.64---------------------\n",
      "--------------------HighestPrice :10.39-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03   9.87   0.06   21515  21235798   买盘\n",
      "1  14:57:00   9.81     --     423    414963   买盘\n",
      "...... total: 4655\n",
      "--->从 09:30:00 到 09:30:00有合适的时间点：1个\n",
      "          time  price change  volume   amount type\n",
      "4653  09:30:00   9.65  -0.06    3831  3696915   卖盘\n",
      "--------------------Data: 2017-05-12--------------------\n",
      "--------------------LowestPrice :8.63---------------------\n",
      "--------------------HighestPrice :9.69-------------------\n",
      "       time  price change  volume   amount type\n",
      "0  15:00:03   9.69     --    4662  4517478   卖盘\n",
      "1  14:57:00   9.69     --     294   284895   卖盘\n",
      "...... total: 4274\n",
      "--->从 10:25:12 到 10:37:48有合适的时间点：61个\n",
      "          time  price change  volume  amount type\n",
      "2951  10:37:48   8.66  -0.03      86   74476   卖盘\n",
      "2976  10:36:27   8.65  -0.02     150  129750   卖盘\n",
      "2978  10:36:21   8.66     --      60   51960   买盘\n",
      "2979  10:36:18   8.66   0.01      31   26846   买盘\n",
      "2980  10:36:15   8.65  -0.01      32   27680   卖盘\n",
      "2981  10:36:12   8.66   0.01      24   20784   买盘\n",
      "2982  10:36:09   8.65     --     243  210195   卖盘\n",
      "2983  10:36:06   8.65     --       5    4325   卖盘\n",
      "2984  10:36:03   8.65     --      11    9515   卖盘\n",
      "2985  10:36:00   8.65  -0.01      57   49305   卖盘\n",
      "2986  10:35:57   8.66   0.02      62   53692  中性盘\n",
      "2987  10:35:54   8.64     --      47   40608   卖盘\n",
      "2988  10:35:51   8.64     --      93   80352   卖盘\n",
      "2989  10:35:48   8.64  -0.01     314  271296   卖盘\n",
      "2990  10:35:45   8.65     --     200  173000   卖盘\n",
      "2991  10:35:42   8.65     --      22   19030   卖盘\n",
      "2992  10:35:39   8.65     --     189  163485   卖盘\n",
      "2993  10:35:36   8.65  -0.01      76   65740   卖盘\n",
      "2994  10:35:33   8.66   0.01     101   87466   买盘\n",
      "2995  10:35:30   8.65     --      61   52765   买盘\n",
      "2996  10:35:27   8.65     --      40   34600   买盘\n",
      "2997  10:35:24   8.65   0.01     236  204140   买盘\n",
      "2998  10:35:21   8.64     --      87   75168   卖盘\n",
      "2999  10:35:18   8.64     --      30   25920   卖盘\n",
      "3000  10:35:15   8.64     --     153  132192   买盘\n",
      "3001  10:35:12   8.64     --      35   30240   买盘\n",
      "3002  10:35:09   8.64  -0.01      44   38016   卖盘\n",
      "3003  10:35:06   8.65   0.01     119  102935   买盘\n",
      "3004  10:35:03   8.64  -0.01      39   33696   卖盘\n",
      "3005  10:35:00   8.65  -0.01      92   79580  中性盘\n",
      "...        ...    ...    ...     ...     ...  ...\n",
      "3007  10:34:54   8.65     --     593  512945   卖盘\n",
      "3008  10:34:51   8.65  -0.01     150  129750   卖盘\n",
      "3009  10:34:48   8.66   0.01     116  100456   买盘\n",
      "3010  10:34:45   8.65     --      84   72660   卖盘\n",
      "3011  10:34:42   8.65     --      27   23355   卖盘\n",
      "3012  10:34:39   8.65  -0.01      19   16435   卖盘\n",
      "3013  10:34:36   8.66     --     123  106518   买盘\n",
      "3014  10:34:33   8.66     --      81   70146   卖盘\n",
      "3015  10:34:30   8.66     --     329  284914   卖盘\n",
      "3016  10:34:27   8.66  -0.01      72   62352   卖盘\n",
      "3028  10:33:51   8.66  -0.01     335  290110   卖盘\n",
      "3171  10:26:18   8.66  -0.01     185  160210   卖盘\n",
      "3174  10:26:09   8.65  -0.01     692  598580   卖盘\n",
      "3175  10:26:06   8.66     --     234  202644   买盘\n",
      "3176  10:26:03   8.66   0.01     157  135962  中性盘\n",
      "3177  10:26:00   8.65  -0.01     324  280260   卖盘\n",
      "3178  10:25:57   8.66     --     225  194850   卖盘\n",
      "3179  10:25:54   8.66     --     128  110848   卖盘\n",
      "3180  10:25:51   8.66   0.01      56   48496  中性盘\n",
      "3181  10:25:48   8.65  -0.01     282  243930   卖盘\n",
      "3182  10:25:45   8.66     --     111   96126   卖盘\n",
      "3183  10:25:42   8.66  -0.01     183  158478   卖盘\n",
      "3185  10:25:36   8.66     --     172  148952   卖盘\n",
      "3186  10:25:33   8.66     --     134  116044   买盘\n",
      "3187  10:25:30   8.66     --      97   84002   买盘\n",
      "3188  10:25:27   8.66     --     135  116910   买盘\n",
      "3189  10:25:24   8.66     --     130  112580   买盘\n",
      "3190  10:25:21   8.66  -0.01     349  302234   卖盘\n",
      "3192  10:25:15   8.66     --      12   10392   卖盘\n",
      "3193  10:25:12   8.66  -0.01      10    8660   卖盘\n",
      "\n",
      "[61 rows x 6 columns]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--------------------Data: 2017-05-11--------------------\n",
      "--------------------LowestPrice :8.05---------------------\n",
      "--------------------HighestPrice :8.95-------------------\n",
      "       time  price change  volume   amount type\n",
      "0  15:00:03   8.81     --    8108  7143148   买盘\n",
      "1  14:57:00   8.81   0.01     125   110125   买盘\n",
      "...... total: 4124\n",
      "--->从 09:38:15 到 09:38:48有合适的时间点：12个\n",
      "          time  price change  volume  amount type\n",
      "3948  09:38:48   8.08   0.02     277  223816   买盘\n",
      "3949  09:38:45   8.06  -0.01     658  530348   卖盘\n",
      "3950  09:38:42   8.07   0.01     205  165435  中性盘\n",
      "3951  09:38:39   8.06  -0.01     426  343356   卖盘\n",
      "3952  09:38:36   8.07   0.02     274  221118   买盘\n",
      "3953  09:38:33   8.05  -0.01     796  640780   卖盘\n",
      "3954  09:38:30   8.06     --     227  182962   买盘\n",
      "3955  09:38:27   8.06     --     452  364312   买盘\n",
      "3956  09:38:24   8.06  -0.01     734  591604   卖盘\n",
      "3957  09:38:21   8.07  -0.01     469  378483   卖盘\n",
      "3958  09:38:18   8.08   0.01     451  364408   买盘\n",
      "3959  09:38:15   8.07  -0.02     354  285678   卖盘\n",
      "--------------------Data: 2017-05-09--------------------\n",
      "--------------------LowestPrice :8.48---------------------\n",
      "--------------------HighestPrice :8.87-------------------\n",
      "       time  price change  volume   amount type\n",
      "0  15:00:03   8.86   0.01    6993  6195798   买盘\n",
      "1  14:57:00   8.85     --     108    95580   卖盘\n",
      "...... total: 4206\n",
      "--->从 09:59:45 到 10:37:33有合适的时间点：33个\n",
      "          time  price change  volume   amount type\n",
      "2920  10:37:33   8.51  -0.01     189   160839   卖盘\n",
      "2935  10:36:48   8.51  -0.01      63    53613   卖盘\n",
      "2938  10:36:39   8.51  -0.02     423   359973   卖盘\n",
      "2940  10:36:33   8.51     --      78    66378   卖盘\n",
      "2941  10:36:30   8.51     --      71    60421   卖盘\n",
      "2942  10:36:27   8.51  -0.01      70    59570   卖盘\n",
      "2944  10:36:21   8.51  -0.01     100    85100   卖盘\n",
      "3011  10:32:57   8.51  -0.01     281   239131   卖盘\n",
      "3015  10:32:45   8.51  -0.01      82    69782   卖盘\n",
      "3018  10:32:36   8.51  -0.01     160   136160   卖盘\n",
      "3020  10:32:30   8.51  -0.01      41    34891   卖盘\n",
      "3023  10:32:21   8.51     --     116    98716   卖盘\n",
      "3024  10:32:18   8.51     --     178   151478   卖盘\n",
      "3025  10:32:15   8.51  -0.01     113    96163   卖盘\n",
      "3027  10:32:09   8.50  -0.01     144   122400   卖盘\n",
      "3028  10:32:06   8.51  -0.01      16    13616   卖盘\n",
      "3030  10:32:00   8.51     --     149   126799   卖盘\n",
      "3031  10:31:57   8.51  -0.01      60    51060   卖盘\n",
      "3033  10:31:51   8.50  -0.03     116    98600   卖盘\n",
      "3037  10:31:39   8.50  -0.04    3784  3216400   卖盘\n",
      "3521  10:04:42   8.51  -0.01     183   155733   卖盘\n",
      "3523  10:04:36   8.51  -0.01     365   310615   卖盘\n",
      "3609  10:00:18   8.51  -0.02     191   162541   卖盘\n",
      "3611  10:00:12   8.50     --     103    87550   卖盘\n",
      "3612  10:00:09   8.50   0.01     666   566100   买盘\n",
      "3613  10:00:06   8.49     --    1218  1034082   卖盘\n",
      "3614  10:00:03   8.49  -0.01     451   382899   卖盘\n",
      "3615  10:00:00   8.50   0.01     515   437750   买盘\n",
      "3616  09:59:57   8.49     --     559   474591   卖盘\n",
      "3617  09:59:54   8.49     --     416   353184   买盘\n",
      "3618  09:59:51   8.49     --     147   124803   卖盘\n",
      "3619  09:59:48   8.49  -0.01     125   106125   卖盘\n",
      "3620  09:59:45   8.50  -0.06    4689  3985650   卖盘\n",
      "--------------------Data: 2017-05-03--------------------\n",
      "--------------------LowestPrice :9.64---------------------\n",
      "--------------------HighestPrice :10.55-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03   10.2     --   18796  19171920   买盘\n",
      "1  14:57:00   10.2     --     670    683400   买盘\n",
      "...... total: 4662\n",
      "--->从 09:51:12 到 09:55:12有合适的时间点：19个\n",
      "          time  price change  volume   amount type\n",
      "4156  09:55:12   9.67  -0.06    2367  2288889   卖盘\n",
      "4219  09:52:03   9.67     --     410   396470   卖盘\n",
      "4220  09:52:00   9.67     --      56    54152   卖盘\n",
      "4221  09:51:57   9.67   0.01     441   426447  中性盘\n",
      "4222  09:51:54   9.66     --     413   399653   买盘\n",
      "4223  09:51:51   9.66     --     868   838488   卖盘\n",
      "4224  09:51:48   9.66     --     679   655914   卖盘\n",
      "4225  09:51:45   9.66     --     511   493626   卖盘\n",
      "4226  09:51:42   9.66   0.01     416   401856  中性盘\n",
      "4227  09:51:39   9.65     --     926   893590   买盘\n",
      "4228  09:51:36   9.65     --     355   342575   买盘\n",
      "4229  09:51:33   9.65     --     402   387930   卖盘\n",
      "4230  09:51:30   9.65  -0.01     673   649445   卖盘\n",
      "4231  09:51:27   9.66     --     521   503286   买盘\n",
      "4232  09:51:24   9.66   0.01     585   565110   买盘\n",
      "4233  09:51:21   9.65  -0.01    1158  1117470   卖盘\n",
      "4234  09:51:18   9.66  -0.01      62    59892   卖盘\n",
      "4235  09:51:15   9.67   0.01     163   157621  中性盘\n",
      "4236  09:51:12   9.66  -0.02     892   861672   卖盘\n",
      "--------------------Data: 2017-05-02--------------------\n",
      "--------------------LowestPrice :9.51---------------------\n",
      "--------------------HighestPrice :9.98-------------------\n",
      "       time  price change  volume    amount type\n",
      "0  15:00:03   9.81     --   14582  14304942   买盘\n",
      "1  14:57:00   9.81     --     819    803439   买盘\n",
      "...... total: 4478\n",
      "--->从 09:30:48 到 09:31:30有合适的时间点：11个\n",
      "          time  price change  volume  amount type\n",
      "4446  09:31:30   9.52  -0.03     670  637840   卖盘\n",
      "4450  09:31:18   9.52     --     332  316064   卖盘\n",
      "4451  09:31:15   9.52     --      77   73304   买盘\n",
      "4452  09:31:12   9.52   0.01      69   65688  中性盘\n",
      "4453  09:31:09   9.51  -0.01     593  563943   卖盘\n",
      "4454  09:31:06   9.52   0.01     169  160888   买盘\n",
      "4455  09:31:03   9.51  -0.07     272  258672   卖盘\n",
      "4457  09:30:57   9.53     --     659  628027   买盘\n",
      "4458  09:30:54   9.53     --     268  255403   买盘\n",
      "4459  09:30:51   9.53  -0.01     314  299242   卖盘\n",
      "4460  09:30:48   9.54  -0.01     268  255671  中性盘\n"
     ]
    }
   ],
   "source": [
    "stock_code1 = '000507' # 先测试一下\n",
    "get_low_price_moment(stock_code1, get_stock_operate_date(stock_code1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
